package com.settlement.system.service.impl;

import com.settlement.system.mapper.BaseMapper;
import com.settlement.system.mapper.TblWpAuditStaticDtlMapper;
import com.settlement.system.common.exception.ServiceException;
import com.settlement.system.model.entity.common.SinglePage;
import com.settlement.system.model.entity.common.TblWpAuditStaticDtlSummary;
import com.settlement.system.service.ITblWpAuditStaticDtlSummaryService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.ResultHandler;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * wp-稽核明细  汇总服务类
 *
 * @author ximi
 * @since 2020-12-09
 */
@Service
@Slf4j
public class TblWpAuditStaticDtlSummaryServiceImpl extends BaseServiceImpl implements ITblWpAuditStaticDtlSummaryService {

    @Resource
    private TblWpAuditStaticDtlMapper tblWpAuditStaticDtlMapper;

    @Override
    public BaseMapper init() {
        return tblWpAuditStaticDtlMapper;
    }

    @Override
    public TblWpAuditStaticDtlSummary getFoot(Map<String, Object> params) throws ServiceException {
        try {
            return tblWpAuditStaticDtlMapper.getSummaryFoot(params);
        } catch (Exception ex) {
            throw new ServiceException("获取稽核汇总合计异常", ex);
        }
    }


    @Override
    public <ModelType> List<ModelType> selectByPage(SinglePage page, Map<String, Object> params, String orderByField, String orderBy) throws ServiceException {
        try {
            return (List<ModelType>) tblWpAuditStaticDtlMapper.selectSummaryByPage(page, params, orderByField, orderBy);
        } catch (Exception ex) {
            log.error("获取汇总分页数据异常", ex);
            throw new ServiceException("获取汇总分页数据异常", ex);
        }
    }


    @Override
    public <ModelType> void getDataByHandler(Map<String, Object> params, ResultHandler<ModelType> handler) throws ServiceException {
        try {
            tblWpAuditStaticDtlMapper.getDataSummaryByHandler(params, (ResultHandler<TblWpAuditStaticDtlSummary>) handler);
        } catch (Exception ex) {
            log.error("流式导出异常", ex);
            throw new ServiceException(ex);
        }
    }
}

